﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using XZTZ.UMP.Public.Models.Base;
using XZTZ.UMP.WEB.Data;

namespace XZTZ.UMP.WEB.Pages.Base.BillTemplet
{
    public class CreateModel : PageModel
    {
        private readonly XZTZ.UMP.WEB.Data.ApplicationDbContext _context;

        public CreateModel(XZTZ.UMP.WEB.Data.ApplicationDbContext context)
        {
            _context = context;
        }

		public IActionResult OnGet()
		{
			ViewData["StrPropertyId"] = new SelectList(_context.Base_BillPropertys, "StrPropertyId", "StrPropertyName");
			ViewData["GuidBillVisionId"] = new SelectList(_context.Base_BillVisions, "GuidBillVisionId", "StrVisionName");
			return Page();
		}

        [BindProperty]
        public XZTZ.UMP.Public.Models.Base.BillTemplet BillTemplet { get; set; }

        public async Task<IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return Page();
            }

            _context.Base_BillTemplets.Add(BillTemplet);
            await _context.SaveChangesAsync();

            return RedirectToPage("./Index");
        }
    }
}